//
// Created by denglibin on 2021/6/3.
//

#include "main_spirit.h"
#include "global.h"
#include "stdio.h"
/**
 * 创建
 * @return
 */
MainSpirit* MainSpiritCreate(SDL_Renderer* renderer){
    MainSpirit* mainSpirit = (MainSpirit* )malloc(sizeof (MainSpirit));
    mainSpirit->w = 32;
    mainSpirit->h = 48;
    mainSpirit->speed = 300;
    mainSpirit->x = 0;
    mainSpirit->y = 0;
    mainSpirit->jumping = 0;
    mainSpirit->move_direction = 0;

    mainSpirit->map_x = 0;
    mainSpirit->map_y = 0;

    return mainSpirit;
}

/**
 * 跳跃
 * @param mainSpirit
 */
void MainSpiritJump(MainSpirit* mainSpirit){
    if(mainSpirit->jumping){
        return;
    }
    mainSpirit->jumping = 1;
    mainSpirit->jump_start_y = mainSpirit->y;
    mainSpirit->jump_start_time = SDL_GetTicks();
}
/**
 * 释放
 * @param mainSpirit
 */
void MainSpiritFree(MainSpirit* mainSpirit){
    free(mainSpirit);
}

